package com.five.admin.controller;

import com.five.controller.BaseController;
import com.five.admin.service.WalletRecordService;
import com.five.entity.ArticleType;
import com.five.entity.Orders;
import com.five.entity.WalletRecords;
import com.five.vo.BaseResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: star
 * @Date: 2021-05-21 14:47
 * 钱包记录 Controller 层
 */
@Controller
@RequestMapping("wallet")
@CrossOrigin
@Api("钱包记录业务接口")
public class WalletRecordsController extends BaseController {

    @Autowired
    private WalletRecordService walletRecordService;

    /**
     * @return订单列表
     */
    /**
     * @return文章类别列表
     */
    @ResponseBody
    @RequestMapping(value = "getWallet",method = RequestMethod.GET)
    @ApiOperation("获取文章类型列表接口")
    public BaseResultVO getArticleType(String walletCode, Integer page){
        List<WalletRecords> list = walletRecordService.fuzzyQueryByWalletCode(walletCode,page);
        System.out.println(list);
        int pages = ((walletRecordService.countWalletRecord(walletCode)-1)/8)+1;
        Map<String,Object> resultMap = new HashMap();
        resultMap.put("pages",pages);
        resultMap.put("walletList",list);
        return successResp(resultMap);
    }

    /**
     * @return订单列表
     */
    @ResponseBody
    @RequestMapping(value = "fuzzyQueryOrder",method = RequestMethod.GET)
    @ApiOperation("模糊查询订单信息")
    public BaseResultVO fuzzyQueryByWalletCode(String walletCode,int page){
        List<WalletRecords> list = walletRecordService.fuzzyQueryByWalletCode(walletCode,page);
        return successResp(list);
    }
}